package com.example;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: Jasic
 * Date: 12-11-5
 */
public class FirstContentProvider extends ContentProvider {

    /**
     * �൱��һ��map�����Ժ���Ҫʹ��ʱ��ƥ��...
     */
    public static final UriMatcher URI_MATCHER;

    public static final int Incoming_user_collection = 1;
    public static final int Incoming_user_single = 2;


    static {
        URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
        URI_MATCHER.addURI(FirstProviderMetaData.Authority, "/users", Incoming_user_collection);
        URI_MATCHER.addURI(FirstProviderMetaData.Authority, "/users/#", Incoming_user_single);
        F
    }

    public static HashMap<String, String> propertiesMap;

    static {
        propertiesMap = new HashMap<String, String>();
    }

    @Override
    public boolean onCreate() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getType(Uri uri) {

        System.out.println("getType....");
        switch (URI_MATCHER.match(uri)) {
            case Incoming_user_collection: {
                return FirstProviderMetaData.UserTableMetaData.Content_Type;
            }

            case Incoming_user_single: {

                return FirstProviderMetaData.UserTableMetaData.Content_Type_Item;
            }

            default: {
                throw new RuntimeException("Can't find the matched metaData...");
            }
        }
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        return 0;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
